package android.slc.module.sys.ui.dict.type

import android.slc.base.ui.AppViewModel
import android.slc.box.core.scope.IntentScope

/**
 * @author slc
 * @date 2022/03/21 下午 3:34
 */
open class DictTypePageVm : AppViewModel() {
    val addEditIntentScope = IntentScope()
    val dictTypePageVmBox by lazy {
        initDictTypePageVmBox()
    }

    fun initVm() {
        registerVmBox(dictTypePageVmBox)
        dictTypePageVmBox.firstRefresh()
        addEditIntentScope.subscribeRefreshList(loadIntentScopeNotification)
    }

    protected open fun initDictTypePageVmBox(): DictTypePageVmSub {
        return DictTypePageVmSub()
    }

    override fun onIntentRefreshList(payload: Any?) {
        super.onIntentRefreshList(payload)
        this.dictTypePageVmBox.firstRefresh()
    }

    override fun onCleared() {
        super.onCleared()
        addEditIntentScope.unSubscribeRefreshList(loadIntentScopeNotification)
    }
}